package com.doit.demo02;

import java.util.concurrent.*;

public class test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //尽量避免使用系统线程池,容易造成oom溢出
        ExecutorService pool = Executors.newFixedThreadPool(3);
        Future<Integer> ft = pool.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                return 10;
            }
        });
        System.out.println(ft.get());

        for (int i = 0; i < 20; i++) {
            pool.submit(new MyRun(i+""));
        }
//        pool.shutdown();
//        for (int i = 0; i < 500; i++) {
//            new Thread();
//        }
    }
}
